home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ULARN.ARJ / ULARN.TAR / ularn / moreobj.c < prev    next >
C/C++ Source or Header  |  1989-10-25  |  9KB  |  476 lines

  1. /* moreobj.c
  2.  *
  3.  *    Routines in this file:
  4.  *
  5.  *    oaltar()
  6.  *    othrone()
  7.  *    ochest()
  8.  *    ofountain()
  9.  */
  10. #include "header.h"
  11.  
  12. /*
  13.  *    ******
  14.  *    OALTAR
  15.  *    ******
  16.  *
  17.  *    subroutine to process an altar object
  18.  */
  19. oaltar()
  20. {
  21.     unsigned long k;
  22.  
  23.     lprcat("\nDo you (p) pray  (d) desecrate"); 
  24.     iopts();
  25.     while (1) {
  26.         while (1) switch(getcharacter()) {
  27.         case 'p':    
  28.              lprcat(" pray\nDo you (m) give money or (j) just pray? ");
  29.             while (1) switch(getcharacter()) {
  30.             case 'j':    
  31.                 if (rnd(100)<75) 
  32.                     lprcat("\nnothing happens");
  33.                 else if (rnd(13)<4) ohear();
  34.                 else if (rnd(43) <= 10) {
  35.                     if (c[WEAR]) 
  36.                         lprcat("\nYou feel your armor vibrate for a moment");
  37.                     enchantarmor();
  38.                     return;
  39.                 }
  40.                 else if (rnd(43) <= 10) {
  41.                     if (c[WIELD]) 
  42.                         lprcat("\nYou feel your weapon vibrate for a moment");
  43.                     enchweapon(); 
  44.                     return;
  45.                 }
  46.                 else createmonster(makemonst(level+2));
  47.                 return;
  48.  
  49.             case 'm':
  50. donate:
  51.                 cursor(1,24);  
  52.                 cltoeoln();
  53.                 cursor(1,23);  
  54.                 cltoeoln();
  55.                 lprcat("how much do you donate? ");
  56.                 k = readnum(c[GOLD]);
  57.                 if (c[GOLD] < k) {     
  58.                     lprcat("You don't have that much!");
  59.                     nap(1001);
  60.                     goto donate;
  61.                 }
  62.                 if ( (k==0 || (k<(c[GOLD]/10)) )
  63.                     && rnd(60)<30) {
  64. lprcat("Cheapskate! The Gods are insulted at such a meager offering!");
  65.                     forget();
  66.                     createmonster(DEMONPRINCE);
  67.                     c[AGGRAVATE] += 1500; 
  68.                     return;
  69.                 }
  70.                 c[GOLD] -= k;
  71.                 if (k < c[GOLD]/10 || k<rnd(50)) { 
  72.                     createmonster(makemonst(level+2)); 
  73.                     c[AGGRAVATE] += 500; 
  74.                 }
  75.                 else if (rnd(101) > 50)    { 
  76.                     ohear(); 
  77.                     return; 
  78.                 }
  79.                 else if (rnd(43) >= 33) {
  80.                     if (c[WEAR]) 
  81.             lprcat("You feel your armor vibrate for a moment");
  82.                     enchantarmor();
  83.                     enchantarmor();
  84.                     return;
  85.                 }
  86.                 else if (rnd(43) >= 33) {
  87.                     if (c[WIELD]) 
  88.             lprcat("You feel your weapon vibrate for a moment");
  89.                     enchweapon(); 
  90.                     enchweapon(); 
  91.                     return;
  92.                 }
  93.                 else    lprcat("Thank You.");
  94.                 bottomline();    
  95.                 return;
  96.             } /* end case j or m */
  97.  
  98.         case 'd': 
  99.             lprcat(" desecrate");
  100.             if (rnd(100)<60) { 
  101.                 createmonster(makemonst(level+3)+8); 
  102.                 c[AGGRAVATE] += 2500; 
  103.             }
  104.             else if(rnd(100)<5) raiselevel();
  105.             else if (rnd(101)<30) {
  106.     lprcat("\nThe altar crumbles into a pile of dust before your eyes");
  107.                 forget();    /*remember to destroy the altar*/
  108.             }
  109.             else lprcat("\nnothing happens");
  110.             return;
  111.  
  112.         case 'i':
  113.         case '\33': 
  114.             ignore();
  115.             if (rnd(100)<30) { 
  116.                 createmonster(makemonst(level+2)); 
  117.                 c[AGGRAVATE] += rnd(450); 
  118.             }
  119.             else    lprcat("\nnothing happens");
  120.             return;
  121.         } /* end pray, des, ignore */
  122.     }
  123. } /* end oaltar */
  124.  
  125. /*
  126.     function to cast a +3 protection on the player
  127.  */
  128. ohear()
  129. {
  130.     lprcat("You have been heard!");
  131.     if (c[ALTPRO]==0) c[MOREDEFENSES]+=5;
  132.     c[ALTPRO] += 800;    /* protection field */
  133.     bottomline();
  134. }
  135.  
  136. /*
  137.     *******
  138.     OTHRONE
  139.     *******
  140.  
  141.     subroutine to process a throne object
  142.  */
  143. othrone(arg)
  144. int arg;
  145. {
  146.     register int i,k;
  147.  
  148.     lprcat("\nDo you (p) pry off jewels, (s) sit down"); 
  149.     iopts();
  150.     while (1) {
  151.         while (1) switch(getcharacter()) {
  152.         case 'p':    
  153.             lprcat(" pry off");  
  154.             k=rnd(101);
  155.             if (k<25) {
  156.                 for (i=0; i<rnd(4); i++) 
  157.                     creategem(); /*gems pop off the throne*/
  158.                 item[playerx][playery]=ODEADTHRONE;
  159.                 know[playerx][playery]=0;
  160.             }
  161.             else if (k<40 && arg==0) {
  162.                 createmonster(GNOMEKING);
  163.                 item[playerx][playery]=OTHRONE2;
  164.                 know[playerx][playery]=0;
  165.             }
  166.             else lprcat("\nnothing happens");
  167.             return;
  168.  
  169.         case 's':     
  170.             lprcat(" sit down");  
  171.             k=rnd(101);
  172.             if (k<30 && arg==0) {
  173.                 createmonster(GNOMEKING);
  174.                 item[playerx][playery]=OTHRONE2;
  175.                 know[playerx][playery]=0;
  176.             }
  177.             else if (k<35) {
  178.                 lprcat("\nZaaaappp!  You've been teleported!\n"); 
  179.                 beep(); 
  180.                 oteleport(0); 
  181.             }
  182.             else lprcat("\nnothing happens");
  183.             return;
  184.  
  185.         case 'i':
  186.         case '\33': 
  187.             ignore(); 
  188.             return;
  189.         };
  190.     }
  191. }
  192.  
  193. odeadthrone()
  194. {
  195.     register int k;
  196.  
  197.     lprcat("\nDo you (s) sit down"); 
  198.     iopts();
  199.     while (1) {
  200.         while (1) switch(getcharacter()) {
  201.         case 's':     
  202.             lprcat(" sit down");  
  203.             k=rnd(101);
  204.             if (k<15) raiselevel();
  205.             else if (k<35) {
  206.                   lprcat("\nZaaaappp!  You've been teleported!\n"); 
  207.                 beep(); 
  208.                 oteleport(0); 
  209.             }
  210.             else lprcat("\nnothing happens");
  211.             return;
  212.  
  213.         case 'i':
  214.         case '\33': 
  215.             ignore(); 
  216.             return;
  217.         };
  218.     }
  219. }
  220.  
  221. /*
  222.     ******
  223.     OCHEST
  224.     ******
  225.  
  226.     subroutine to process a chest object
  227.  */
  228. ochest()
  229. {
  230.     register int i,k;
  231.  
  232.     lprcat("\nDo you (t) take it, (o) try to open it"); 
  233.     iopts();
  234.     while (1) {
  235.         while (1) switch(getcharacter()) {
  236.         case 'o':    
  237.             lprcat(" open it");  
  238.             k=rnd(101);
  239.             if (k<40) {
  240.                 lprcat("\nThe chest explodes as you open it"); 
  241.                 beep();
  242.                 i = rnd(10);  
  243.                 lastnum=281;  /* in case he dies */
  244.             lprintf("\nYou suffer %d hit points damage!",(long)i);
  245.                 checkloss(i);
  246.                 switch(rnd(10))    {
  247.                 case 1:    
  248.                     c[ITCHING]+= rnd(1000)+100;
  249.         lprcat("\nYou feel an irritation spread over your skin!");
  250.                     beep();
  251.                     break;
  252.  
  253.                 case 2:    
  254.                     c[CLUMSINESS]+= rnd(1600)+200;
  255.             lprcat("\nYou begin to lose hand to eye coordination!");
  256.                     beep();
  257.                     break;
  258.  
  259.                 case 3:    
  260.                     c[HALFDAM]+= rnd(1600)+200;
  261.     lprcat("\nYou suddenly feel sick and BARF all over your shoes!");    
  262.                     beep();
  263.                     break;
  264.                 };
  265.                 item[playerx][playery]=know[playerx][playery]=0;
  266.                 if (rnd(100)<69) 
  267.                     creategem(); /* gems from the chest */
  268.                 dropgold(rnd(110*iarg[playerx][playery]+200));
  269.                 for (i=0; i<rnd(4); i++) 
  270.                     something(iarg[playerx][playery]+2);
  271.             }
  272.             else lprcat("\nnothing happens");
  273.             return;
  274.  
  275.         case 't':    
  276.             lprcat(" take");
  277.             if (take(OCHEST,iarg[playerx][playery])==0)
  278.                 item[playerx][playery]=know[playerx][playery]=0;
  279.             return;
  280.  
  281.         case 'i':
  282.         case '\33': 
  283.             ignore(); 
  284.             return;
  285.         };
  286.     }
  287. }
  288.  
  289. /*
  290.     *********
  291.     OFOUNTAIN
  292.     *********
  293.  */
  294.  
  295. ofountain()
  296. {
  297.     register int x;
  298.  
  299.     cursors();
  300.     lprcat("\nDo you (d) drink, (w) wash yourself"); 
  301.     iopts();
  302.     while (1) switch(getcharacter()) {
  303.     case 'd':    
  304.         lprcat("drink");
  305.         if (rnd(1501)<4) {
  306.         lprcat("\nOops!  You seem to have caught the dreadful sleep!");
  307.             beep(); 
  308.             lflush();  
  309.             sleep(3);  
  310.             died(280); 
  311.             return;
  312.         }
  313.         x = rnd(100);
  314.         if (x==1) raiselevel();
  315.         else if (x < 11) {     
  316.             x=rnd((level<<2)+2);
  317. lprintf("\nBleah! The water tasted like stale gatorade! You suffer %d hit points!", (long)x);
  318.             lastnum=273; 
  319.             losehp(x); 
  320.             bottomline();  
  321.             cursors();
  322.         }
  323.         else if (x<14) {     
  324.             c[HALFDAM] += 200+rnd(200);
  325.             lprcat("\nThe water makes you vomit");
  326.         }
  327.         else if (x<17) 
  328.             quaffpotion(17); /* giant strength */
  329.         else if (x < 45)
  330.             lprcat("\nnothing seems to have happened");
  331.         else if (rnd(3) != 2)
  332.             fntchange(1);    /*change char levels upward*/
  333.         else
  334.             fntchange(-1);    /*change char levels downward*/
  335.         if (rnd(12)<3) {      
  336.             lprcat("\nThe fountains bubbling slowly quiets");
  337.             /* dead fountain */
  338.             item[playerx][playery]=ODEADFOUNTAIN; 
  339.             know[playerx][playery]=0;
  340.         }
  341.         return;
  342.  
  343.     case '\33':
  344.     case 'i':    
  345.         ignore();  
  346.         return;
  347.     case 'w':    
  348.         lprcat("wash yourself");
  349.         if (rnd(100) < 11) {     
  350.             x=rnd((level<<2)+2);
  351. lprintf("\nOh no!  The water burns like acid!  You suffer %d hit points!",(long)x);
  352.             lastnum=273; 
  353.             losehp(x); 
  354.             bottomline();  
  355.             cursors();
  356.         }
  357.         else if (rnd(100) < 29)
  358.             lprcat("\nYou are now clean!");
  359.         else if (rnd(100) < 31)
  360.           lprcat("\nThis water needs soap!  The dirt didn't come off!");
  361.         else if (rnd(100) < 34)
  362.             createmonster(WATERLORD); 
  363.         else lprcat("\nnothing seems to have happened");
  364.         return;
  365.     }
  366. }
  367.  
  368. /*
  369.     a subroutine to raise or lower character levels
  370.     if how > 0 they are raised   if how < 0 they are lowered
  371.  */
  372. fntchange(how)
  373. int how;
  374. {
  375.     register long j;
  376.  
  377.     lprc('\n');
  378.     switch(rnd(9))
  379.     {
  380.     case 1:    
  381.         lprcat("Your strength");    
  382.         fch(how,&c[0]);    
  383.         break;
  384.     case 2:    
  385.         lprcat("Your intelligence");    
  386.         fch(how,&c[1]);    
  387.         break;
  388.     case 3:    
  389.         lprcat("Your wisdom");
  390.         fch(how,&c[2]);    
  391.         break;
  392.     case 4:    
  393.         lprcat("Your constitution");
  394.         fch(how,&c[3]);    
  395.         break;
  396.     case 5:    
  397.         lprcat("Your dexterity");
  398.         fch(how,&c[4]);    
  399.         break;
  400.     case 6:    
  401.         lprcat("Your charm");
  402.         fch(how,&c[5]);    
  403.         break;
  404.     case 7:    
  405.         j=rnd(level+1);
  406.         if (how < 0) {     
  407.             lprintf("You lose %d hit point",(long)j);  
  408.             if (j>1) lprcat("s!"); 
  409.             else lprc('!'); 
  410.             losemhp((int)j); 
  411.         }
  412.         else {     
  413.             lprintf("You gain %d hit point",(long)j);  
  414.             if (j>1) lprcat("s!"); 
  415.             else lprc('!'); 
  416.             raisemhp((int)j); 
  417.         }
  418.         bottomline();        
  419.         break;
  420.     case 8:    
  421.         j=rnd(level+1);
  422.         if (how > 0) {     
  423.             lprintf("You just gained %d spell",(long)j);  
  424.             raisemspells((int)j);
  425.             if (j>1) lprcat("s!"); 
  426.             else lprc('!');
  427.         }
  428.         else {     
  429.             lprintf("You just lost %d spell",(long)j);
  430.             losemspells((int)j);
  431.             if (j>1) lprcat("s!"); 
  432.             else lprc('!');
  433.         }
  434.         bottomline();    
  435.         break;
  436.     case 9:    
  437.         j = 5*rnd((level+1)*(level+1));
  438.         if (how < 0) {     
  439.             lprintf("You just lost %d experience point",(long)j);
  440.             if (j>1) lprcat("s!"); 
  441.             else lprc('!'); 
  442.             loseexperience((long)j);
  443.         }
  444.         else {     
  445.             lprintf("You just gained %d experience point",(long)j);
  446.             if (j>1) lprcat("s!"); 
  447.             else lprc('!'); 
  448.             raiseexperience((long)j);
  449.         }
  450.         break;
  451.     }
  452.     cursors();
  453. }
  454.  
  455. /*
  456.     ***
  457.     FCH
  458.     ***
  459.  
  460.     subroutine to process an up/down of a character attribute for ofountain
  461.  */
  462. fch(how,x)
  463. int how;
  464. long *x;
  465. {
  466.     if (how < 0)     {     
  467.         lprcat(" went down by one!");    
  468.         --(*x); 
  469.     } 
  470.     else {     
  471.         lprcat(" went up by one!");    
  472.         (*x)++; 
  473.     }
  474.     bottomline();
  475. }
  476.